package com.xw.mykotlin

import android.content.Intent
import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.ViewModelProvider
import com.xw.kotlinlib.app.immersion
import com.xw.kotlinlib.app.setStatusBarsLightMode
import com.xw.kotlinlib.base.BaseActivity
import com.xw.mykotlin.R
import com.xw.mykotlin.databinding.ActivityMainBinding

class MainActivity : BaseActivity() {

    private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
    private val viewModel by lazy { ViewModelProvider(this)[MainViewModel::class.java] }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        window?.setStatusBarsLightMode(true)
        window?.statusBarColor = Color.TRANSPARENT
        window?.immersion()

        binding.btnLivedata.setOnClickListener {
            viewModel.liveData("23008",1)
        }

        binding.btnFlow.setOnClickListener {
            startActivity(Intent(this,MainActivity2::class.java))
        }

        observer()
    }

    private fun observer() {

        viewModel.categorys.observe(this) {
            Log.d("info", "====数据长度====" + it.size)
        }
    }

}